from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet
from django.contrib.auth.models import Permission,ContentType
from rest_framework.permissions import IsAdminUser
from meiduo_admin.serializers.permissions import PerssionsSerializer, ContentTypeserialzier
from meiduo_admin.utils import PageNum
class PermissionsView(ModelViewSet):
    serializer_class = PerssionsSerializer
    queryset = Permission.objects.all()
    pagination_class = PageNum
    permission_classes = [IsAdminUser]

    def content_type(self,request):
        #获取权限类型
        # 获取所有的权限类型
        data = ContentType.objects.all()
        #序列化返回权限类型
        ser = ContentTypeserialzier(data,many=True)
        return Response(ser.data)
